using System;

namespace FreeFlow.Administration
{
	/// <summary>
	/// Base class for data-aware classes.
	/// </summary>
	public abstract class DatabaseAware
	{
		internal DatabaseAware(Server server)
		{
      if (server == null)
        throw new ArgumentNullException("server", "server parameter must be supplied");
      this.server = server;
		}

    private Server server;
    /// <summary>
    /// Gets the server.
    /// </summary>
    public Server Server
    {
      get
      {
        return server;
      }
    }

    /// <summary>
    /// Escapes a string so that single quotes are replaced by two quotes for use in SQL expressions.
    /// </summary>
    /// <param name="sql">The string to escape.</param>
    /// <returns>The escaped string</returns>
    public static string SqlEscape(string sql)
    {
      if (sql == null)
        return null;
      return sql.Replace("'", "''");
    }

    internal const string readOnlyListMessage = "List is read-only";
	}
}
